package com.destiny.commons.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResultVO<T> {
  /** 默认成功码 */
  public static final int SUCCESS_CODE = 200;

  /** 默认成功消息 */
  public static final String SUCCESS_MSG = "success";

  /** 默认失败码 */
  public static final int ERROR_CODE = 201;

  /** 默认失败消息 */
  public static final String ERROR_MSG = "系统异常！";

  /** 响应码 */
  private Integer code;

  /** 响应消息 */
  private String msg;

  /** 响应结果 */
  private T data;

  public static <T> ResultVO<T> success(T data) {
    return new ResultVO<>(SUCCESS_CODE, SUCCESS_MSG, data);
  }

  public static <T> ResultVO<T> error() {
    return new ResultVO<>(ERROR_CODE, ERROR_MSG, null);
  }

  public static <T> ResultVO<T> error(String msg) {
    return new ResultVO<>(ERROR_CODE, msg, null);
  }

}
